'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: 1_simple_chat_bot.py
* @Time: 2025/10/23
* @All Rights Reserve By Brtc
'''
from multiprocessing.connection import answer_challenge

import dotenv
from openai import OpenAI

dotenv.load_dotenv()

client = OpenAI(base_url="https://api.ephone.chat/v1")

if __name__ == "__main__":
    while True:
        human_input = input("你好我是博小睿客服助手,请输入您的问题>")
        if human_input == "exit":
            print("goodbye!!")
            exit(0)

        completion = client.chat.completions.create(
            model="gpt-4o-mini",
            messages=[
                {"role":"system", "content":"你是OpenAi研发聊天机器人"},
                {"role":"user", "content":human_input},
            ],
            stream = True
        )
        print("博小睿:", end = "", flush=True)
        for chunk in completion:
            content = chunk.choices[0].delta.content
            if content  is None:
                break
            print(content, end = "", flush=True)
        print("\n---------------------------------------------\n")
